#!/bin/sh
#
# Copyright (c) 2021, 2022 Obeo.
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#     Obeo - initial API and implementation

DASH_JAR="$1"

[ -f "$DASH_JAR" ] || {
    echo "Usage: $0 path/to/org.eclipse.dash.licenses.jar"
    echo "See https://github.com/eclipse/dash-licenses"
    exit 1
}

ROOT_DIR="$(dirname "$0")/.."

echo "Checking backend dependencies..."
MAVEN_DEPS=$(mktemp)
mvn -q -B verify -f "$ROOT_DIR/packages/pom.xml" dependency:list -DskipTests -Dmaven.javadoc.skip=true -DappendOutput=true -DoutputFile="$MAVEN_DEPS"
java -jar "$DASH_JAR" "$MAVEN_DEPS"

echo
echo "Checking frontend dependencies..."
java -jar "$DASH_JAR" "$ROOT_DIR/frontend/package-lock.json"
